//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using OpenLS.Core.Serialization;

namespace OpenLS.Chart.UI
{
    class ChartSampleConverter: IMultiValueConverter
    {
        class SampleNumericReference : NumericReference
        {
            public override string Formula
            {
                get { throw new NotSupportedException(); }
            }

            public override IEnumerable<NumericValue> NumericValues
            {
                get
                {
                    yield return new NumericValue(this, 0, 0.3);
                    yield return new NumericValue(this, 1, 0.8);
                }
            }
        }
            class SampleDataSource : NumericDataSource
            {
                public SampleDataSource()
                {
                    reference = new SampleNumericReference();
                }
                SampleNumericReference reference;
                public override IEnumerable<NumericValue> NumericValues
                {
                    get
                    {
                        return reference.NumericValues;

                    }
                }


                protected override void ReadXmlCore(ReadContext context)
                {
                    throw new NotSupportedException();
                }

                protected override void WriteXmlCore(WriteContext context)
                {
                    throw new NotSupportedException();
                }
            }
        

        
            #region IMultiValueConverter Members

            public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
            {
                BarChart result = new BarChart();
                BarSeries series = new BarSeries();
                series.Values = new SampleDataSource();
                result.Series.Add(series);
                ChartArea space = new ChartArea();
                space.PlotArea.Charts.Add(result);
                space.Style = (ChartStyle)values[0];
                result.CategoryAxis.MajorGridLines = null;
                result.ValueAxis.MajorGridLines = null;
                return result;
            }

            public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
            {
                throw new NotSupportedException();
            }

            #endregion
        }
}
